﻿(function () {
    "use strict";
    var page = WinJS.UI.Pages.define("default.html", {
        ready: function (element, options) {
            document.getElementById("cmdFavorite")
                .addEventListener("click", doClickFavorite, false);
            document.getElementById("cmdRecord")
                .addEventListener("click", doClickRecord, false);
            document.getElementById("cmdPlay")
                .addEventListener("click", doClickPlay, false);
            document.getElementById("cmdExplore")
                .addEventListener("click", doClickExplore, false);
            WinJS.log && WinJS.log("To show the bar, swipe up from " +
                "the bottom of the screen, right-click, or " +
                "press Windows Logo + z. To dismiss the bar, " +
                "tap in the application, swipe, right-click, " +
                "or press Windows Logo + z again.", "sample", "status");
        },
    });

    // Command button functions
    function doClickFavorite() {
        player.stop();
        clearTimeout(gLoop);
        WinJS.Navigation.navigate("/pages/groupDetail/groupDetail.html",{ groupKey: "grpFavorite" });
    }

    function doClickRecord() {
        
        WinJS.Navigation.navigate("/pages/home/home.html", { action: "Record" });
        initialized();
    }

    function doClickPlay() {
        
        WinJS.Navigation.navigate("/pages/home/home.html", { action: "Play" });
        initialized();
    }

    function doClickExplore() {
        player.stop();
        clearTimeout(gLoop);
        var item = Data.items.getAt(args.detail.itemIndex);
        WinJS.Navigation.navigate("/pages/groupedItems/groupedItems.html");
    }

    WinJS.log = function (message) {
        var statusDiv = document.getElementById("statusMessage");
        if (statusDiv) {
            statusDiv.innerText = message;
        }
    };
})();
